import Vue from 'vue'
import VueRouter from 'vue-router'
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
return originalPush.call(this, location).catch(err => err)
}
Vue.use(VueRouter)
const routes = [{
        path: '/',
        name: 'home',
        component: () => import('../views/home.vue'),
        meta: {
            title: '首页'
        },
       }
]

const router = new VueRouter({
    routes,
    scrollBehavior(to, from, savedPosition) {
        // 解决路由跳转后 会滚动到底部
        if (savedPosition) {
            return savedPosition
        } else {
            return {
                x: 0,
                y: 0
            }
        }
    }
})

export default router
